home *** CD-ROM | disk | FTP | other *** search
- Path: news.voicenet.com!news
- From: kobak@voicenet.com (Peter Kobak)
- Newsgroups: comp.lang.c++
- Subject: Re: A beginners valiant effort.
- Date: 22 Feb 1996 15:55:13 GMT
- Organization: Voicenet - Internet Access - (215)674-9290
- Message-ID: <4gi3l1$kou@news.voicenet.com>
- NNTP-Posting-Host: ivyland243.voicenet.com
- X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
-
- You didn't leave enough room in string_val_one for the string's terminator.
-
- In message <4g81kr$mrs@soap.news.pipex.net> - chris.neale@ooh.conqueror.co.uk
- (Chris Neale) writes:
- :>
- :>Please, Please! Help! Why doesn't this work - the book says it should,
- :>but the IF statement falls through - like a switch statement. Try it
- :>and see.
- :>
- :>Thanks, Chris
- :>
- :>please e-mail responses to neales@dial.pipex.com - Ta.
- :>
- :>
- :>#include <iostream.h>
- :>#include <string.h>
- :>
- :>enum boolean{false, true};
- :>
- :>class switc_string
- :> {
- :> private:
- :> char string_val_one[16];
- :> char string_val_two[12];
- :> public:
- :> void set_string(char string1[], char string2[])
- :> {
- :> strcpy(string_val_one, string1);
- :> strcpy(string_val_two, string2);
- :> }
- :> void get_string(boolean string_index)
- :> {
- :> cout << string_index;
- :> if ( string_index )
- :> {cout << string_val_one;}
- :>
- :> else
- :> {cout << string_val_two;}
- :> }
- :> };
- :>
- :>void main()
- :>
- :>{
- :>
- :>switc_string s1;
- :>s1.set_string("is not flowering","is flowering");
- :>cout << endl;
- :>s1.get_string(1);
- :>
- :>}
- :>
- :>
-
-
-
- ================
- Peter Kobak
- kobak@voicenet.com
-
-
-